package com.csweimei.rentmanagementtreasure.tenant.ui.act.customer;

import androidx.appcompat.app.AppCompatActivity;
import androidx.lifecycle.ViewModelProviders;

import android.os.Bundle;
import android.view.View;

import com.chad.library.BR;
import com.csweimei.rentmanagementtreasure.R;
import com.csweimei.rentmanagementtreasure.base.AppConfig;
import com.csweimei.rentmanagementtreasure.base.AppViewModelFactory;
import com.csweimei.rentmanagementtreasure.databinding.ActivityCustomerInfoBinding;
import com.csweimei.rentmanagementtreasure.http.entity.CustomerBean;
import com.csweimei.rentmanagementtreasure.tenant.viewModel.CustomerInfoVm;
import com.csweimei.rentmanagementtreasure.utils.GlideHandler;
import com.google.android.material.tabs.TabLayout;

import me.goldze.mvvmhabit.base.BaseActivity;

public class CustomerInfoActivity extends BaseActivity<ActivityCustomerInfoBinding, CustomerInfoVm> {


    @Override
    public int initContentView(Bundle savedInstanceState) {
        return R.layout.activity_customer_info;
    }

    @Override
    public int initVariableId() {
        return BR.viewModel;
    }

    String customerId;
    String type;

    @Override
    public void initParam() {
        super.initParam();
        customerId = getIntent().getStringExtra(AppConfig.BUNDLE_KEY);
        type = getIntent().getStringExtra(AppConfig.BUNDLE_KEY2);
    }

    @Override
    public void initData() {
        super.initData();
        viewModel.setActivity(this);
        viewModel.customerId.set(customerId + "");


        viewModel.setShareView(binding.shareView);

        if (type.equals("ent")) {
            viewModel.setRightIconVisible(View.GONE);

        } else {
            viewModel.setRightIconVisible(View.VISIBLE);

        }


        binding.tab.addTab(binding.tab.newTab().setText("跟进记录"));
        binding.tab.addTab(binding.tab.newTab().setText("看房意向"));
        binding.tab.getTabAt(0).select();
        viewModel.getTabData();

        binding.tab.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
            @Override
            public void onTabSelected(TabLayout.Tab tab) {
                viewModel.type.set("" + tab.getPosition());
                viewModel.getTabData();
            }

            @Override
            public void onTabUnselected(TabLayout.Tab tab) {

            }

            @Override
            public void onTabReselected(TabLayout.Tab tab) {

            }
        });


    }

    @Override
    public CustomerInfoVm initViewModel() {
        AppViewModelFactory factory = AppViewModelFactory.getInstance(getApplication());
        return ViewModelProviders.of(this, factory).get(CustomerInfoVm.class);
    }
}